package control;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.admin.OptionalServiceVO;
import model.happy.HappyTimeService;
import model.happy.ListVO;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;


public class HappyTimeController extends MultiActionController{
	private HappyTimeService happyTimeService;
	
	public HappyTimeController(HappyTimeService happyTimeService) {
		super();
		this.happyTimeService = happyTimeService;
	}
	
	public ModelAndView happyTimeList(HttpServletRequest request,HttpServletResponse response){
		String pageNo=request.getParameter("pageNo");
		ListVO listVO=null;
		try {
			listVO = happyTimeService.happytime(pageNo);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return new ModelAndView("happy_time_result.happy","result",listVO);
	}
	//신랑 신부 아이디와 입력한 비밀번호를 비교하여 OptionalService 테이블에 존재하는지 확인하는 메서드
	public ModelAndView intoAlbum(HttpServletRequest request,HttpServletResponse response,OptionalServiceVO osvo){
		try {
			osvo=happyTimeService.intoAlbum(osvo);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return new ModelAndView("JsonView","osvo",osvo);
	}
	//신랑 신부 아이디로 직접찾기
	public ModelAndView coupleFindById(HttpServletRequest request,HttpServletResponse response){
		String id=request.getParameter("id");
		HashMap couple=null;
		try {
			couple=happyTimeService.coupleFindById(id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(couple);
		return new ModelAndView("JsonView","couple",couple);
	}
	public ModelAndView showHappyMoney(HttpServletRequest request,HttpServletResponse response){
		List list=null;
		try {
			list=happyTimeService.showHappyMoney();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return new ModelAndView("result_happy_money.happy","result",list);
	}
}
